<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin_menus', function (Blueprint $table) {
            $table->id();
            $table->integer('parent_id')->default(0)->comment('父级Id');
            $table->string('name', 50)->default('')->comment('菜单名称');
            $table->string('path', 255)->default('')->comment('菜单路径');
            $table->string('action', 100)->default('')->comment('菜单方法');
            $table->string('icon', 100)->default('')->comment('菜单图标');
            $table->string('module_type', 20)->default('')->comment('菜单模型分类:extend_列表');
            $table->tinyInteger('level')->default(0)->comment('菜单等级');
            $table->tinyInteger('facility')->default(0)->comment('是否是操作类型:0=否,1=是');
            $table->integer('sort')->default(0)->comment('排序:数字越小越靠前');
            $table->tinyInteger('status')->default(0)->comment('状态:1=正常,2=禁用');
            $table->tinyInteger('is_delete')->default(0)->comment('是否删除:1=删除,0=正常');
            $table->integer('created_at')->default(0)->comment('创建时间');
            $table->integer('updated_at')->default(0)->comment('修改时间');
        });
        DB::statement("ALTER TABLE `admin_menus` comment '【后台】菜单'");
        // 初始化菜单表
        DB::table('admin_menus')->insert([
            [
                'id'          => 1,
                'parent_id'   => 0,
                'name'        => '系统设置',
                'path'        => '#',
                'action'      => '',
                'icon'        => 'el-icon-s-tools',
                'module_type' => 'extend',
                'level'       => 1,
                'facility'    => 1,
                'sort'        => 1000,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 2,
                'parent_id'   => 1,
                'name'        => '权限设置',
                'path'        => '#',
                'action'      => '',
                'icon'        => '',
                'module_type' => 'extend',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 10,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 3,
                'parent_id'   => 2,
                'name'        => '菜单管理',
                'path'        => 'framework/manage/menus',
                'action'      => '',
                'icon'        => '',
                'module_type' => 'extend',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 10,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 4,
                'parent_id'   => 2,
                'name'        => '管理员',
                'path'        => 'framework/manage/users',
                'action'      => '',
                'icon'        => '',
                'module_type' => 'extend',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 20,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 5,
                'parent_id'   => 2,
                'name'        => '组织管理',
                'path'        => 'framework/manage/group',
                'action'      => '',
                'icon'        => '',
                'module_type' => 'extend',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 30,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 6,
                'parent_id'   => 2,
                'name'        => '角色管理',
                'path'        => 'framework/manage/role',
                'action'      => '',
                'icon'        => '',
                'module_type' => 'extend',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 40,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 7,
                'parent_id'   => 3,
                'name'        => '新增',
                'path'        => 'framework/manage/menus/insert',
                'action'      => 'insert',
                'icon'        => 'el-icon-circle-plus-outline',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 8,
                'parent_id'   => 3,
                'name'        => '编辑',
                'path'        => 'framework/manage/menus/update',
                'action'      => 'update',
                'icon'        => 'el-icon-edit',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 9,
                'parent_id'   => 3,
                'name'        => '删除',
                'path'        => 'framework/manage/menus/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 10,
                'parent_id'   => 3,
                'name'        => '状态',
                'path'        => 'framework/manage/menus/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 11,
                'parent_id'   => 3,
                'name'        => '模型',
                'path'        => 'framework/manage/menus/module',
                'action'      => 'module',
                'icon'        => 'el-icon-s-help',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 12,
                'parent_id'   => 4,
                'name'        => '新增',
                'path'        => 'framework/manage/users/insert',
                'action'      => 'insert',
                'icon'        => 'el-icon-circle-plus-outline',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 13,
                'parent_id'   => 4,
                'name'        => '编辑',
                'path'        => 'framework/manage/users/update',
                'action'      => 'update',
                'icon'        => 'el-icon-edit',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 14,
                'parent_id'   => 4,
                'name'        => '删除',
                'path'        => 'framework/manage/users/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 15,
                'parent_id'   => 4,
                'name'        => '状态',
                'path'        => 'framework/manage/users/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 16,
                'parent_id'   => 5,
                'name'        => '新增',
                'path'        => 'framework/manage/group/insert',
                'action'      => 'insert',
                'icon'        => 'el-icon-circle-plus-outline',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 17,
                'parent_id'   => 5,
                'name'        => '编辑',
                'path'        => 'framework/manage/group/update',
                'action'      => 'update',
                'icon'        => 'el-icon-edit',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 18,
                'parent_id'   => 5,
                'name'        => '删除',
                'path'        => 'framework/manage/group/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 19,
                'parent_id'   => 5,
                'name'        => '状态',
                'path'        => 'framework/manage/group/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 20,
                'parent_id'   => 6,
                'name'        => '新增',
                'path'        => 'framework/manage/role/insert',
                'action'      => 'insert',
                'icon'        => 'el-icon-circle-plus-outline',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 21,
                'parent_id'   => 6,
                'name'        => '编辑',
                'path'        => 'framework/manage/role/update',
                'action'      => 'update',
                'icon'        => 'el-icon-edit',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 22,
                'parent_id'   => 6,
                'name'        => '删除',
                'path'        => 'framework/manage/role/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 23,
                'parent_id'   => 6,
                'name'        => '状态',
                'path'        => 'framework/manage/role/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'module_type' => '',
                'level'       => 4,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 24,
                'parent_id'   => 1,
                'name'        => '系统日志',
                'path'        => '#',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 25,
                'parent_id'   => 24,
                'name'        => '登录日志',
                'path'        => 'framework/manage/log/login',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 26,
                'parent_id'   => 24,
                'name'        => '访问日志',
                'path'        => 'framework/manage/log/access',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 27,
                'parent_id'   => 25,
                'name'        => '清空日志',
                'path'        => 'framework/manage/log/login/clear',
                'action'      => 'clear',
                'icon'        => 'el-icon-delete-solid',
                'module_type' => '',
                'level'       => 3,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 28,
                'parent_id'   => 26,
                'name'        => '清空日志',
                'path'        => 'framework/manage/log/access/clear',
                'action'      => 'clear',
                'icon'        => 'el-icon-delete-solid',
                'module_type' => '',
                'level'       => 3,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 29,
                'parent_id'   => 1,
                'name'        => '后台设置',
                'path'        => 'framework/setup/page/setting',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 30,
                'parent_id'   => 1,
                'name'        => '文件存储',
                'path'        => 'framework/setup/page/file',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 31,
                'parent_id'   => 1,
                'name'        => '第三方扩展',
                'path'        => '',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 2,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 32,
                'parent_id'   => 31,
                'name'        => '微信开发配置',
                'path'        => 'framework/setup/page/wechat',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 33,
                'parent_id'   => 31,
                'name'        => '阿里开发配置',
                'path'        => 'framework/setup/page/ali_config',
                'action'      => '',
                'icon'        => '',
                'module_type' => '',
                'level'       => 3,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 34,
                'parent_id'   => 0,
                'name'        => '控制台',
                'path'        => '/',
                'action'      => '',
                'icon'        => 'el-icon-s-shop',
                'module_type' => 'extend',
                'level'       => 1,
                'facility'    => 1,
                'sort'        => 1,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'id'          => 35,
                'parent_id'   => 0,
                'name'        => '网站配置',
                'path'        => 'arts/setup/page/site_base',
                'action'      => '',
                'icon'        => 'el-icon-help',
                'module_type' => 'extend',
                'level'       => 1,
                'facility'    => 1,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
        ]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_menus');
    }
};
